﻿<Controls:PhoneApplicationPage x:Class="TexasHoldemCalculator.View.SkyDriveFileExplorerView"
                               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                               xmlns:Controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                               xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                               xmlns:MvvmLite="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP71"
                               xmlns:my="clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI"
                               xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                               x:Name="StartingHandsSelectionViewPage"
                               ApplicationBar="{StaticResource GlobalApplicationBar}"
                               d:DesignHeight="800"
                               d:DesignWidth="480"
                               DataContext="{Binding Source={StaticResource Locator}, Path=SkyDrive}"
                               Style="{StaticResource DefaultPageTransition}"
                               SupportedOrientations="Portrait"
                               mc:Ignorable="d">
    <Grid x:Name="LayoutRoot">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="65" />
                <RowDefinition Height="*" />
                <RowDefinition Height="85" />
            </Grid.RowDefinitions>

            <TextBlock Style="{StaticResource THCStatsLargeHeaderText}" Text="{Binding CurrentDirectory}" />

            <ListBox x:Name="SkyDriveItemListBox"
                        Grid.Row="1"
                        Height="571"
                        HorizontalAlignment="Stretch"
                        ItemsSource="{Binding Files}"
                        VirtualizingStackPanel.VirtualizationMode="Standard">
                <ListBox.ItemTemplate>
                    <DataTemplate x:Name="MyDataTemplate">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="48" />
                                <ColumnDefinition Width="*" />

                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>

                            <Grid Grid.Row="0" Grid.Column="1">
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                </Grid.RowDefinitions>

                                <TextBlock x:Name="tbHiddenId"
                                            Width="Auto"
                                            FontSize="24"
                                            FontWeight="Bold"
                                            Text="{Binding FileId}"
                                            Visibility="Collapsed" />
                                <TextBlock x:Name="tbHiddenType"
                                            Width="Auto"
                                            FontSize="24"
                                            FontWeight="Bold"
                                            Text="{Binding Type}"
                                            Visibility="Collapsed" />
                                <TextBlock x:Name="tbHiddenFileLink"
                                            Width="Auto"
                                            FontSize="24"
                                            FontWeight="Bold"
                                            Text="{Binding Link}"
                                            Visibility="Collapsed" />
                                <TextBlock x:Name="tbHiddenFileSource"
                                            Width="Auto"
                                            FontSize="24"
                                            FontWeight="Bold"
                                            Text="{Binding FileSource}"
                                            Visibility="Collapsed" />
                                <TextBlock x:Name="tbHiddenParent"
                                            Width="Auto"
                                            FontSize="24"
                                            FontWeight="Bold"
                                            Text="{Binding ParentId}"
                                            Visibility="Collapsed" />

                                <Button x:Name="btnFileName"
                                        Grid.Row="0"
                                        Margin="0"
                                        HorizontalAlignment="Left"
                                        VerticalAlignment="Center"
                                        BorderBrush="Transparent">
                                    <Button.Content>
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition />
                                            </Grid.RowDefinitions>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="60" />
                                                <ColumnDefinition Width="10" />
                                                <ColumnDefinition Width="300*" />
                                            </Grid.ColumnDefinitions>

                                            <Image Width="Auto"
                                                    Height="Auto"
                                                    Source="{Binding PictureIcon}" />

                                            <StackPanel Grid.Column="2" Orientation="Vertical">
                                                <toolkit:WrapPanel>
                                                    <TextBlock x:Name="tbFileName"
                                                                FontSize="20"
                                                                FontStyle="Italic"
                                                                FontWeight="Bold"
                                                                Text="{Binding FileName}" />
                                                </toolkit:WrapPanel>
                                                <TextBlock x:Name="tbFileCreated"
                                                            FontSize="17"
                                                            Text="{Binding CreatedTime}" />
                                                <TextBlock x:Name="tbFileSize"
                                                            FontSize="17"
                                                            Text="{Binding FileSizeInformation}" />
                                                <toolkit:WrapPanel>
                                                    <TextBlock x:Name="tbFileSharingInformation"
                                                                FontSize="17"
                                                                Text="{Binding FileSharingInformation}" />
                                                </toolkit:WrapPanel>
                                            </StackPanel>
                                        </Grid>
                                    </Button.Content>
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Click">
                                            <MvvmLite:EventToCommand x:Name="SkyDriveFileSelectedCommand"
                                                                        Command="{Binding ElementName=StartingHandsSelectionViewPage,
                                                                                        Path=DataContext.SkyDriveFileSelectedCommand}"
                                                                        CommandParameter="{Binding ElementName=tbHiddenId, Path=Text}" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </Grid>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

            <my:AdControl x:Name="THCSkyDriveExplorerAd"
                            Grid.Row="3"
                            Width="{Binding Width}"
                            Height="{Binding Height}"
                            Margin="0"
                            VerticalAlignment="Center"
                            DataContext="{Binding Source={StaticResource Locator},
                                                Path=AdProvider}" />
        </Grid>

        <ItemsControl x:Name="SkyDriveLoadingFolderListingsPopup"
                      Template="{StaticResource SkyDriveFolderListingProgressIndicatorControleTemplate}"
                      DataContext="{Binding Source={StaticResource Locator}, Path=SkyDrive}"
                      Visibility="{Binding Visibility2}" />

        <!--<ItemsControl x:Name="WTF"
                      Template="{StaticResource SkyDriveDownloadConfirmationPopup}"
                      DataContext="{Binding Source={StaticResource Locator}, Path=SkyDrive}"
                      Visibility="{Binding Visiblity1}" />-->
        
        <ItemsControl x:Name="DownloadConfirmationPopup"
                      Template="{StaticResource SkyDriveDownloadConfirmationPopup}"
                      DataContext="{Binding Source={StaticResource Locator}, Path=SkyDrive}"
                      Visibility="{Binding Visibility1}" />
    </Grid>
</Controls:PhoneApplicationPage>